home *** CD-ROM | disk | FTP | other *** search
/ Sun Solutions 2000 #2 / Sun Solutions CD (Volume 2 2000)(Special Focus - Java Technologies)(Disc 1).ISO / products / Software / TornadoLabsLimited / book / KeyNavigateTest / Light.java < prev    next >
Text File  |  2000-01-13  |  2KB  |  56 lines

  1. /*
  2. //*****************************************************************************
  3. /*
  4. *    @(#) Light.java
  5. *
  6. *    Project:        Java 3D Programming
  7. *    Client:        Manning Publications
  8. *
  9. *    Copyright (c) 1999 Daniel Selman 
  10. *    All Rights Reserved.
  11. *
  12. *    @author Daniel Selman: dselman@tornadolabs.com
  13. */
  14. //*****************************************************************************
  15.  
  16. import javax.vecmath.*;
  17. import javax.media.j3d.*;
  18. import java.awt.*;
  19. import java.net.*;
  20.  
  21. import com.sun.j3d.utils.image.*;
  22. import com.sun.j3d.utils.geometry.*;
  23.     
  24. import com.tornadolabs.dselman.j3d.book.*;
  25.  
  26. public class Light extends ComplexObject
  27. {    
  28.     private TextureAttributes        m_TextureAttributes = null;
  29.     
  30.     public Light( Component comp, Group g, int nFlags )
  31.     {
  32.         super( comp, g, nFlags );
  33.     }
  34.                 
  35.     protected Group createGeometryGroup( Appearance app, Vector3d position, Vector3d scale, String szTextureFile, String szSoundFile )
  36.     {                        
  37.         Group g = new Group();
  38.         
  39.         app.setPolygonAttributes( new PolygonAttributes( PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_NONE, 0, false ) );
  40.         app.setTransparencyAttributes( new TransparencyAttributes( TransparencyAttributes.BLENDED, 1.0f ) );
  41.         
  42.         m_TextureAttributes = new TextureAttributes( TextureAttributes.REPLACE, new Transform3D(), new Color4f(0,0,0,1), TextureAttributes.FASTEST );
  43.         app.setTextureAttributes( m_TextureAttributes );
  44.  
  45.         if( (m_nFlags & ComplexObject.TEXTURE) == ComplexObject.TEXTURE )
  46.             setTexture( app, szTextureFile );
  47.         
  48.         Cone cone = new Cone( 1, 1, Primitive.GENERATE_TEXTURE_COORDS, app );
  49.         
  50.         g.addChild( cone );
  51.         
  52.         attachBehavior( new TextureAnimationBehavior( m_TextureAttributes ) );
  53.         
  54.         return g;
  55.     }
  56. }